home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / dynaweb.idb / usr / lib / Insight / dweb / sgi5 / bin / stop.z / stop
Encoding:
Text File  |  1997-07-30  |  2.2 KB  |  102 lines

  1. #!/bin/csh -f
  2. #
  3. # $Id: stop 1.2 1997/02/12 16:31:24 mma Exp $
  4. #
  5. # Copyright (c) 1991-1997, Inso Corporation
  6. # All Rights Reserved.
  7. #
  8. #
  9. # Usage: stop|restart [service]
  10. #
  11. #   This script stops (or restarts) the specified dynaweb service (as
  12. #   defined in the dwhttpd.cfg file).
  13. #
  14. #   The action (stop or restart) taken by this script is determined by the 
  15. #   script's name.  If the script is named "restart", the selected service 
  16. #   (or services) will be sent the restart signal.  Any other name for this
  17. #   script causes a quit signal to be sent to the desired service(s).
  18. #
  19. #   If the service parameter is absent the main server controller is
  20. #   signaled.  When this process is stopped all subordinate protocol
  21. #   modules will terminate.
  22. #
  23. #   If a service name (or regexp) is provided, only the services whose 
  24. #   name matches the regexp will be signaled accordingly.
  25. #
  26. #####################################################################
  27.  
  28. #
  29. # Determine which command we're running.  We need to know this so we
  30. # can determine which signal to send at our target.
  31. #
  32.  
  33. set cmdname = $0
  34. set cmdname=`echo $cmdname:t`
  35.  
  36. #
  37. # See if the user has specified where the pid file is located.  If
  38. # not, use a suitable default and check to see that it exists.
  39. #
  40.  
  41. if ($?DWEB_PIDLOG) then
  42.    set pidlog=$DWEB_PIDLOG
  43. else
  44.    set pidlog=pid.log
  45. endif
  46.  
  47. if (! -e $pidlog) then
  48.    echo "Unable to open '${pidlog}'.  Is the server running?"
  49.    exit
  50. endif
  51.  
  52.  
  53. #
  54. # Check for the service name that the user wants to blow away.  If
  55. # one isn't specified, nail the server-controller process.
  56. #
  57.  
  58. if ($#argv < 1) then
  59.    set target=server-controller
  60. else
  61.    set target=$argv[1]
  62. endif
  63.  
  64.  
  65. #
  66. # Find the pid to nuke!
  67. #
  68.  
  69. set pid=(`grep $target pid.log | awk '{print $1}'`)
  70.  
  71.  
  72. #
  73. # Check to see if we could we find the pid.  If not, give the user a list.
  74. #
  75.  
  76. if ($#pid == 0) then
  77.    echo 'Invalid service name\!  Please select one of: '
  78.    awk '{printf "\t%s\n", $2}' $pidlog
  79.    exit
  80. endif
  81.  
  82.  
  83. #
  84. # Determine which signal to send to the process based on which
  85. # operation we're performing (e.g. stop, restart)
  86. #
  87.  
  88. if ($cmdname == "restart") then
  89.    set signal=1
  90. else
  91.    set signal=3
  92. endif
  93.  
  94.  
  95. #
  96. # Finally, nail the process
  97. #
  98.  
  99. kill -$signal $pid
  100.  
  101.  
  102.